<template>
  <a-modal destroyOnClose title="权限管理" :okText="$t('common.confirm')" :cancelText="$t('common.cancel')" :visible="visible" :width="520" @cancel="cancelModal(false)" @ok="cancelModal(true)" class="AddAcct">
      <a-checkbox-group :options="gropList" v-model="value" class="group"></a-checkbox-group>
  </a-modal>
</template>

<script>
import { permissionList } from '@/api/config'
export default {
  name: 'AddAcct',
  props: ['visible', 'permissions'],
  data () {
    return {
      gropList: null,
      value: []
    }
  },
  computed: {
  },
  created () {
    this.initData()
  },
  watch: {
    visible: {
      handler (newValue, oldValue) {
        if (newValue) {
          this.value = this.permissions
        }
      },
      immediate: true
    }
  },
  methods: {
    onChange () {

    },
    async initData () {
      let res = await permissionList()
      if (res.code === 200) {
        this.gropList = res.data
      // this.gropList = [
      //   { label: '新增职位', value: 'addPosition', applicationType: 'VERTICAL_RECRUITMENT', orderIndex: 0, id: '5f4de5d0455223b7add506e7' },
      //   { label: '修改职位', value: 'editPosition', applicationType: 'VERTICAL_RECRUITMENT', orderIndex: 1, id: '5f4de5d0455223b7add506e8' },
      //   { label: '修改企业配置', value: 'editCompany', applicationType: 'VERTICAL_RECRUITMENT', orderIndex: 2, id: '5f4de5d0455223b7add506e9' },
      //   { label: '管理用户', value: 'manageUser', applicationType: 'VERTICAL_RECRUITMENT', orderIndex: 3, id: '5f4de5d0455223b7add506ea' }
      // ]
      } else {
        this.$notify.error(res.message)
      }
    },
    cancelModal (flag) {
      this.$emit('cancelModal', { value: JSON.stringify(this.value) === '[]' ? null : this.value, flag })
    }
  }
}
</script>

<style lang="stylus" scoped>
@import '../../styles/var.styl'
.group
  display flex
  flex-direction column
  :global(.ant-checkbox-group-item)
    margin-bottom 6px
</style>
